package com.bright.hxj.cwduijie.constant;

import com.bright.hxj.cwduijie.pojo.bo.ProcInfo;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * @Author hxj
 * @Date 2024/7/14 09:45
 * @Description 系统常量
 */

//@Component
public class SystemConstants {

    /**
     * 接口总批次数
     */
    public static final int TOTAL_BATCH_COUNT;

    /**
     * 批次顺序 key=当前批次 value=下一批次
     */
    public static final Map<String, String> NEXT_BATCH_MAP = new LinkedHashMap<>();
    /**
     * 按批次推送月份数据
     */
    public static final Map<String, String> MONTHLY_NEXT_BATCH_MAP = new LinkedHashMap<>();

    /**
     * 异步任务查询的最大等待天数 超过就算超时
     */
    public static final int WAIT_DUE_MAX_DAYS = 31;

    /**
     * 默认最多推送1000条
     */
    public static final int DEFAULT_BATCH_SIZE = 1000;

    static {
        NEXT_BATCH_MAP.put("km", "pz");
        NEXT_BATCH_MAP.put("pz", "dcf");
        NEXT_BATCH_MAP.put("dcf", "bdc");
        NEXT_BATCH_MAP.put("bdc", "yj");
        NEXT_BATCH_MAP.put("yj", null);

        TOTAL_BATCH_COUNT = NEXT_BATCH_MAP.size();

        // v1.6.7 拟增加逐月按批次推送功能 先推月份数据 再推月结 再推下个月
        // 注意这些名称不要太长 否则batchId超长
        MONTHLY_NEXT_BATCH_MAP.put("yj1", "yfsj");
        MONTHLY_NEXT_BATCH_MAP.put("yfsj", "yj");
        MONTHLY_NEXT_BATCH_MAP.put("yj", null);

    }


    // v1.9 生成数据的存储过程key与存储过程名称对应表
    public final static Map<String, ProcInfo> PROC_KEY_MAP = new HashMap<>();

    static {
        // 参数是3个int值
        List<Integer> THREE_INT_ARGS = Arrays.asList(ProcInfo.INT, ProcInfo.INT, ProcInfo.INT);

        PROC_KEY_MAP.put("DZ_AUTO", new ProcInfo("DZ_AUTO", THREE_INT_ARGS, false));
        PROC_KEY_MAP.put("DZ_SPT", new ProcInfo("DZ_SPT", THREE_INT_ARGS, true));
        PROC_KEY_MAP.put("DZ_GDZC", new ProcInfo("DZ_GDZC", THREE_INT_ARGS, true));

//        List<ProcInfo.ProcArg> YEARS_MONTHS_ACC_SET = Arrays.asList(ProcInfo.ACC_SET, ProcInfo.YEARS, ProcInfo.MONTHS);
//        List<ProcInfo.ProcArg> YEARS_MONTHS_ACC_MODAL = Arrays.asList(ProcInfo.YEARS, ProcInfo.MONTHS, ProcInfo.ACC_MODAL);
        List<ProcInfo.ProcArg> SINGLE_ACC_SET = Collections.singletonList(ProcInfo.ACC_SET);
//
//        PROC_KEY_MAP.put("DZ_AUTO", new ProcInfo("DZ_AUTO", YEARS_MONTHS_ACC_MODAL, false));
//        for (String procKey : Arrays.asList("DZ_SPT", "DZ_GDZC")) {
//            PROC_KEY_MAP.put(procKey, new ProcInfo(procKey, YEARS_MONTHS_ACC_SET));
//        }
    }

    public final static Integer PROC_RESULT_STATUS_EXECUTING = 0; // 执行中
    public final static Integer PROC_RESULT_STATUS_SUCCESS = 1; // 执行成功
    public final static Integer PROC_RESULT_STATUS_FAIL = 2; // 执行失败
    public final static Integer PROC_RESULT_STATUS_INTERRUPT = 9; // 执行被用户中止

}
